﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IFServerDLL.DB;

namespace IFClientDLL.MyCalc.Data.Candle
{
    public class MyData_Candle_Minute:MyData_ListTicks
    {
        public MyData_Candle_Minute(MyData_IF data, MyData_Candle_Minute prevData):base(data)
        {
           
            _preCandle = prevData;
            MyData_Candle_Minute line = this;
            while (true)
            {
                if (line == null)
                    break;
                _list.Add(line);
                line = line.PreCandle;
            }
            _MinuteTime = new DateTime(data.MarketTime.Year, data.MarketTime.Month, data.MarketTime.Day, data.MarketTime.Hour, data.MarketTime.Minute, 0);
            AddData(data);
        }
        public override void AddData(MyData_IF data)
        {
            base.AddData(data);
            if (_list.Count > 0)
            {
                _AvgPrice = _list.Average(p => p.ClosePrice);
            }
            else
            {
                _AvgPrice = data.AvgPrice;
            }
        }
        private decimal _AvgPrice;
        public decimal AvgPrice { get { return _AvgPrice; } }
        private DateTime _MinuteTime;
        public DateTime MinuteTime { get { return _MinuteTime; } }
       
        private List<MyData_Candle_Minute> _list=new List<MyData_Candle_Minute>();
        public List<MyData_Candle_Minute> ListAllCandle { get { return _list; } }
        private MyData_Candle_Minute _preCandle;
        public MyData_Candle_Minute PreCandle { get { return _preCandle; } }

       
       
    }
}
